package Test;

//饿汉模式
class Sin{
    //创建唯一的实例
    private static Sin sin = new Sin();
    //禁止实例化
    private Sin(){

    }
    //让拿到唯一的实例
    public static Sin getSin(){
        return sin;
    }
}
//懒汉模式
class Sin2{
    volatile private static Sin2 sin2 = null;
    private Sin2(){

    }
    public static Sin2 getSin2() {
        if (sin2 == null) {
            if (sin2 == null) {
                sin2 = new Sin2();
            }
        }

            return sin2;

    }
}
public class Test18 {
    public static void main(String[] args) {
        Sin sin1 = Sin.getSin();
        Sin sin2 = Sin.getSin();
        System.out.println(sin1 == sin2);
    }
    //翻转链表
//    public ListNode reverseList(ListNode head) {
//        if(head == null || head.next == null) return head;
//        ListNode newHead = reverseList(head.next);
//        head.next.next = head;
//        head.next = null;
//        return newHead;
//    }
}
